﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Metier;

namespace WebApp.Controllers
{
    [Authorize(Roles = "Manager")]
    public class DashboardController : Controller
    {
        // GET: /Dashboard/
        GestionReport gestionReport = new GestionReport();

        public ActionResult Index()
        {
            return View("Dashboard");
        }

        public ActionResult Dashboard()
        {
            DashboardModelView modelviewdashboard = new DashboardModelView();
            try
            {
                modelviewdashboard.rapportDashboardDouble.Add(gestionReport.ChiffreAffaireParRestaurant());
                modelviewdashboard.rapportDashboard.Add(gestionReport.NombreCommande("jour"));
                modelviewdashboard.rapportDashboard.Add(gestionReport.PlatLePlusCommandes("jour"));
            }
            catch (Exception e)
            {
                FlashHelpers.FlashError(this, "Erreur pendant la recuperation des rapports");
            }
            return View(modelviewdashboard);
        }
        public ActionResult Dashboard_hebdo()
        {
            DashboardModelView modelviewdashboard = new DashboardModelView();
            try
            {
                modelviewdashboard.rapportDashboardDouble.Add(gestionReport.ChiffreAffaireParRestaurant());
                modelviewdashboard.rapportDashboard.Add(gestionReport.NombreCommande("semaine"));
                modelviewdashboard.rapportDashboard.Add(gestionReport.PlatLePlusCommandes("semaine"));
            }
            catch (Exception e)
            {
                FlashHelpers.FlashError(this, "Erreur pendant la recuperation des rapports");
            }
            return View(modelviewdashboard);
        }

        public ActionResult Dashboard_mens()
        {
            DashboardModelView modelviewdashboard = new DashboardModelView();
            try
            {
                modelviewdashboard.rapportDashboardDouble.Add(gestionReport.ChiffreAffaireParRestaurant());
                modelviewdashboard.rapportDashboard.Add(gestionReport.NombreCommande("mois"));
                modelviewdashboard.rapportDashboard.Add(gestionReport.PlatLePlusCommandes("mois"));
            }
            catch (Exception e)
            {
                FlashHelpers.FlashError(this, "Erreur pendant la recuperation des rapports");
            }
            return View(modelviewdashboard);
        }

        public ActionResult Dashboard_annu()
        {
            DashboardModelView modelviewdashboard = new DashboardModelView();
            try
            {
                modelviewdashboard.rapportDashboardDouble.Add(gestionReport.ChiffreAffaireParRestaurant());
                modelviewdashboard.rapportDashboard.Add(gestionReport.NombreCommande("annee"));
                modelviewdashboard.rapportDashboard.Add(gestionReport.PlatLePlusCommandes("annee"));
            }
            catch (Exception e)
            {
                FlashHelpers.FlashError(this, "Erreur pendant la recuperation des rapports");
            }
            return View(modelviewdashboard);
        }

        public ActionResult Cook()
        {
            return View();
        }

        public ActionResult Server()
        {
            return View();
        }
    }
}
